<script setup>
	import { util } from '/common/util.js'
	import { ref , reactive, nextTick } from 'vue'
	import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
	onLaunch(()=>{
		loginVerify()
	})
	/**
	 * 登录汇总
	 */
	const loginVerify = async () =>{
		const loginrlt = await mpLogin()
		const mprlt = await mpInfo(loginrlt.code)
		uni.setStorageSync('qhMpUser',mprlt.data);
	}
	/**
	 * 小程序登录
	 */
	const mpLogin = ()=>{
		return new Promise((resolve, reject) => {
			wx.login({
				provider: 'weixin',
				onlyAuthorize:true,
				success: (res) => resolve(res),
				fail:(err) => reject(err)
			})
		})
	}
	
	/**
	 * 获取小程序用户
	 */
	const mpInfo = (code)=>{
		return util.request({url:'/mpwechat/sessioncode',data:{code:code}});
	}
</script>

<style lang="scss">
	.apps{background-color: #ddd5fd; min-height: 100vh; color:#666;}
</style>
